﻿@using LERP.Web.App_Start
@using Sharp.Framework
@using Sharp.Framework.Extensions

@model MvcContrib.Pagination.IPagination<LERP.Web.Controllers.ViewModels.CustomerViewModels.CustomerGoodsViewModel>
@{
    ViewBag.Title = "客户货品配置";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="empty" style="text-align: left;background-color: #FFFCEB;font-size: 14px;font-family: 宋体,Arial,Lucida,Verdana,Helvetica,sans-serif;">
    
    <strong>客户编号: @this.ViewContext.RouteData.Values["id"] </strong>    <strong>名称: @ViewBag.CustomerName   </strong> 
</div>
            @using (Html.BeginForm("Goods", "Customer", FormMethod.Get))
            {
                <table class="table_input" style="width: 100%;">
                    <tr>
                        <th style="width: 100px;">货品类别:</th>
                        <td style="width: 130px;">@Html.DropDownList("categoryId", (ViewBag.GoodsCategorys as List<SelectListItem>).InsertEmpty(), new { @class = "text-medium", style = "width: 99%;" })</td>
                        <th style="width: 100px;">关键字:</th>
                        <td style="width: 130px;">@Html.TextBox("keyword", "", new { @class = "text-medium", style = "width: 80%;" })</td>
                        <td>
                            <input type="submit" class="button-submit" value="查询" /> 
  </td>
                    </tr>
                </table>
            }
            @if (Model != null && Model.Any())
            {

                <table class="table_list" style="width: 99%;">
                    <tr>
                        <th style="width: 80px;">货品编码</th>
                        <th style="width: 80px;">国际条码</th>
                        <th>货品名称</th>
                        <th style="width: 80px;">单位</th>
                        <th style="width: 80px;">默认单价</th>
                        <th style="width: 80px;">配置单价</th>
                        <th style="width: 80px;">操作</th>
                    </tr>
                    @foreach (var item in Model)
                    {
                        var color = (item.Level == 0 ? "" : (item.Level == 1 ? "red" : "crimson"));
                        var title = (item.Level == 0 ? "未配置" : (item.Level == 1 ? "已配置" : "继承配置"));

                        <tr title="@title" class="@color">
                            <td>@item.Id</td>
                            <td>@item.Gencod</td>
                            <td>@item.Name</td>
                            <td>@item.Unit</td>
                            <td>@item.Price</td>
                            <td>
                                <form name="post_@item.Id" action="@Request.RawUrl" method="post">
                                    @Html.Hidden("goodsId", item.Id)
                                    @Html.TextBox("customerPrice", item.CustomerPrice, new {@class = "text-small num", onkeyup = "this.value=this.value.replace(/[^\\d\\.]/g,'')", onafterpaste = "this.value=this.value.replace(/[^\\d\\.]/g,'')"})
                                </form> 
                            </td>
                
                            <td class="action">
                                <a id="command_@item.Id" href="#" onclick="document.forms['post_@item.Id'].submit();return false;">确定</a> 
                                @if(item.Level == 1)
                                {
                                    @Html.ActionLinkEx("取消","DeleteGoodsPrice","Customer",new {goodsId = item.Id,id=ViewContext.RouteData.Values["id"],returnUrl = Request.RawUrl},new{onclick="return window.confirm('您确认要取消当前货品价格配置么?');" })
                                }
                            </td>
                        </tr>
                    }
         
                            
                </table>
                <div class="page">
                    @Html.Pager("page", Model.PageSize, Model.TotalItems)
                </div>
            }
            else
            {
                <div class="empty">
                    查询信息为空
                </div>
            }
